<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>appscript | 10. Reference Examples</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="all"><!--@import url(full.css);--></style>

</head>
<body>

<h1>10. Reference Examples</h1>

<!-- top navigation -->
<div class="navbar">
	<a href="09_referenceforms.html">Previous</a> | <a href="index.html">Up</a> | <a href="11_applicationcommands.html">Next</a>
	
</div>

<!-- content -->
<div id="content">
<h2>Application objects</h2>

<pre><code>// application &quot;Finder&quot;

#import "FNGlue.h"

FNApplication *finder = [[FNApplication alloc]
                          initWithName: @"Finder.app"]



// application &quot;Macintosh HD:Applications:TextEdit.app:&quot;

#import "TEGlue.h"

TEApplication *textedit = [[TEApplication alloc]
                            initWithPath: @"/Applications/TextEdit.app"]</code></pre>


<h2>Property references</h2>

<pre><code>// a reference to startup disk of application &quot;Finder&quot;
[finder startupDisk]

// a reference to name of folder 1 of home of application &quot;Finder&quot;
[[[[finder home] folders] at: 1] name]

// a reference to name of every item of home of application &quot;Finder&quot;
[[[finder home] items] name]

// a reference to text of every document of application &quot;TextEdit&quot;
[[textedit documents] text]

// a reference to color of character 1 of every paragraph of text &not;
//     of document 1 of application &quot;TextEdit&quot;
[[[[[[[textedit documents] at: 1] text] paragraphs] characters] at: 1] color]</code></pre>


<h2>All elements references</h2>

<pre><code>// a reference to disks of application &quot;Finder&quot;
[finder disks]

// a reference to every word of every paragraph of text of every document &not;
//     of application &quot;TextEdit&quot;
[[[[textedit documents] text] paragraphs] words]</code></pre>


<h2>Single element references</h2>

<pre><code>// a reference to disk 1 of application &quot;Finder&quot;
[[finder disks] at: 1]

// a reference to file &quot;ReadMe.txt&quot; of folder &quot;Documents&quot; of home of application &quot;Finder&quot;
[[[[[finder home] folders] byName: @"Documents"] files] byName: @"ReadMe.txt"]

// a reference to paragraph -1 of text of document 1 of application &quot;TextEdit&quot;
[[[[[textedit documents] at: 1] text] paragraphs] at: -1]

// a reference to middle paragraph of text of last document of application &quot;TextEdit&quot;
[[[[[textedit documents] last] text] paragraphs] middle]

// a reference to any file of home of application &quot;Finder&quot;
[[[finder home] files] any]</code></pre>


<h2>Relative references</h2>

<pre><code>// a reference to paragraph before paragraph 6 of text of document 1 of application &quot;TextEdit&quot;
[[[[[[textedit documents] at: 1] text] paragraphs] at: 6] previous: [TEConstant paragraph]]

// a reference to paragraph after character 30 of document 1 of application &quot;Tex-Edit Plus&quot;
[[[[[texEditPlus documents] at: 1] characters] at: 30] next: [TEConstant paragraph]]</code></pre>


<h2>Element range references</h2>

<pre><code>// a reference to words 1 thru 4 of text of document 1 of application &quot;TextEdit&quot;
[[[[[textedit documents] at: 1] text] words] at: 1 to: 4]

// a reference to paragraphs 2 thru -1 of text of document 1 of application &quot;TextEdit&quot;
[[[[[textedit documents] at: 1] text] paragraphs] at: 2 to: -1]

// a reference to folders &quot;Documents&quot; thru &quot;Music&quot; of home of application &quot;Finder&quot;
[[[finder home] folders] byRange: @"Documents" to: @"Music"]

// a reference to text (word 3) thru (paragraph 7) of document 1 of application &quot;Tex-Edit Plus&quot;
[[[[texEditPlus documents] at: 1] text] byRange: [[TEPCon words] at: 3]
                                             to: [[TEPCon paragraphs] at: 7]]</code></pre>


<h2>Test references</h2>

<pre><code>// a reference to every document of application &quot;TextEdit&quot; whose text is &quot;\n&quot;
[[textedit documents] byTest: [[TEIts text] equals: @"\n"]]

// a reference to every paragraph of document 1 of application &quot;Tex-Edit Plus&quot; &not;
//      whose first character is last character
[[[[texEditPlus documents] at: 1] paragraphs] byTest:
        [[[TEPIts characters] first] equals: [[TEPIts characters] last]]]

// a reference to every file of folder &quot;Documents&quot; of home of application &quot;Finder&quot; &not;
//      whose name extension is &quot;txt&quot; and size < 10240
[[[[[finder home] folders] byName: @"Documents"] files] byTest:
        [[[FNIts nameExtension] equals: @"txt"] AND: 
                [[FNIts size] lessThan: [NSNumber numberWithInt: 10240]]]]</code></pre>


<h2>Insertion location references</h2>

<pre><code>// a reference to end of documents of application &quot;TextEdit&quot;
[[textedit documents] end]

// a reference to before paragraph 1 of text of document 1 of application &quot;TextEdit&quot;
[[[[[[textedit documents] at: 1] text] paragraphs] at: 1] before]</code></pre>



</div>

<!-- bottom navigation -->
<div class="navbar">
	<a href="09_referenceforms.html">Previous</a> | <a href="index.html">Up</a> | <a href="11_applicationcommands.html">Next</a>
	
</div>

<!--footer-->
<p class="footer">&copy; 2007 HAS</p>
</body>
</html>